<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        var a = 10
            b = 20
        var temp //var一个空容器

            temp = a //此时temp为10
            a = b // b为20 a=b a此时也为20
            b = temp //temp为10 b=temp 此时b为10
            console.log(a,b,temp); // 20 10 已完成交换

            //不引入第三方容器
            c = 10
            d = 20
            c = c + d // 10+20=30
            d = c - d // 30-20=10
            c = c - d // 30-10=20
            console.log(c , d);
            
    </script>
</body>
</html>